<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" th:href="@{favicon.ico}">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{/dist/css/bootstrap.min.css}" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link th:href="@{/assets/css/ie10-viewport-bug-workaround.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{/css/signin.css}" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script th:src="@{/assets/js/ie8-responsive-file-warning.js}"></script><![endif]-->
    <script th:src="@{/assets/js/ie-emulation-modes-warning.js}"></script>
  </head>

  <body>

    <div class="container">

      <form action="/login" method="post" class="form-signin" id="myform">
        <h2 class="form-signin-heading">Please sign in</h2>
        <label for="inputEmail" class="sr-only">Email address</label>
        <input type="text" id="inputEmail" class="form-control" name="username" placeholder="Your account" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" class="form-control" name="password" placeholder="Password" required>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
        <div class="checkbox">
          <label>
            您是第 <span th:text="${count}"></span> 位访问者。
          </label>
          <label>
            启动时间 <span th:text="${startTime}"></span>
          </label>
        </div>
      </form>

    </div> <!-- /container -->


    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script th:src="@{/assets/js/ie10-viewport-bug-workaround.js}"></script>
    <script th:src="@{/js/jquery/jquery-3.4.1.min.js}"></script>
    <script th:src="@{/js/layer/layer.min.js}"></script>
  <script>
    $(document)
            .ajaxStart(function(){
              $("button:submit").val("Submit...").attr("disabled", true);
            })
            .ajaxStop(function(){
              $("button:submit").val("Sign in").attr("disabled", false);
            });

    $("form").submit(function(){
      var self = $(this);
      $.post(self.attr("action"), self.serialize(), success, "json");
      return false;

      function success(data){
        if(0==data.code){
          return layer.msg(data.msg, {icon: 2,shade: [0.5]});
        }

        location.href="/user/index";
      }
    });
  </script>
  </body>
</html>
